package chenji.moreitemfunapi.textures.info;

import java.io.File;
import java.util.Properties;

import org.bukkit.Material;

import chenji.moreitemfunapi.util.ItemUtil;

public class ArmorInfo extends TextureInfo {
	public static final String chainmail_layer_1 = "chainmail_layer_1";
	public static final String chainmail_layer_2 = "chainmail_layer_2";
	public static final String diamond_layer_1 = "diamond_layer_1";
	public static final String diamond_layer_2 = "diamond_layer_2";
	public static final String gold_layer_1 = "gold_layer_1";
	public static final String gold_layer_2 = "gold_layer_2";
	public static final String iron_layer_1 = "iron_layer_1";
	public static final String iron_layer_2 = "iron_layer_2";
	public static final String leather_layer_1 = "leather_layer_1";
	public static final String leather_layer_2 = "leather_layer_2";
	public static final String leather_layer_1_overlay = "leather_layer_1_overlay";
	public static final String leather_layer_2_overlay = "leather_layer_2_overlay";

	private static final String TYPE = "armor";
	private ItemInfo item;

	protected ArmorInfo(String pluginName, String itemName, Material itemtype) {
		super(pluginName, itemName, itemtype);
		item = new ItemInfo(pluginName, itemName, itemtype);
		item.setPropertiesFileName(item.getPropertiesFileName() + "dly");
		super.setHaveDefault(false);
		if (ItemUtil.isChainArmor(itemtype)) {
			super.addTexture(chainmail_layer_1);
			super.addTexture(chainmail_layer_2);
			return;
		}
		if (ItemUtil.isDiamondArmor(itemtype)) {
			super.addTexture(diamond_layer_1);
			super.addTexture(diamond_layer_2);
			return;
		}
		if (ItemUtil.isgoldArmor(itemtype)) {
			super.addTexture(gold_layer_1);
			super.addTexture(gold_layer_2);
			return;
		}
		if (ItemUtil.isIronArmor(itemtype)) {
			super.addTexture(iron_layer_1);
			super.addTexture(iron_layer_2);
			return;
		}
		if (ItemUtil.isLeatherArmor(itemtype)) {
			super.addTexture(leather_layer_1);
			super.addTexture(leather_layer_2);
			super.addTexture(leather_layer_1_overlay);
			super.addTexture(leather_layer_2_overlay);
			return;
		}
	}

	@Override
	public Properties getProperties() {
		return super.getProperties(TYPE);
	}

	@Override
	public boolean isDone() {
		return super.getNotUpdatedTextures().isEmpty();
	}

	@Override
	public boolean update(String name, File path) {
		super.auts.add(name);
		return true;
	}

	@Override
	public String getPropertiesFileName() {
		return super.getItemName();
	}

	@SuppressWarnings("deprecation")
	public Properties getItemProperties() {
		Properties p = new Properties();
		p.setProperty("type", "item");
		p.setProperty("items", Integer.toString(super.getItemType().getId()));
		p.setProperty("texture", this.getItemFileName());
		p.setProperty("nbt.miftexturesname", super.getItemName());
		return p;
	}

	public String getItemPropName() {
		return super.getItemName() + "_item";
	}

	public String getItemFileName() {
		return super.getItemName() + "_item";

	}

}
